package com.huang;

/**
 * @author HuangShen
 * @Description
 * @create 2021-03-23 7:48
 */
public class Stu implements Comparable<Stu>{

    private  String name;
    private int age;

    @Override
    public String toString() {
        return "Stu{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public Stu(String name, int age) {
        this.name = name;
        this.age = age;
    }

    @Override
    public int compareTo(Stu o) {

        if (name.compareTo(o.name)==0){
            return Integer.compare(age,o.age);
        }
        return name.compareTo(o.name);
    }
}
